/**
 * 
 */
package genealogy.deprecated.datamodel.pedigree.comparator;

import genealogy.deprecated.datamodel.pedigree.Date;

/**
 * @author Steve
 * @invariant 
 */
@Deprecated
public class DateComparator {

	
	public Double compareDates(Date date1, Date date2){
		if(date1 == null || date1.getNumberOfParts() == 0|| date2 == null || date2.getNumberOfParts() == 0){
			return null;
		}
		
		float totalScore = .5f;
		float yearScore, monthScore, dayScore;

		float yearDifference = (date1.getYear()==0 || date2.getYear()==0)? 5f : Math.abs(date1.getYear() - date2.getYear());
		float monthDifference = (date1.getMonth()==0 || date2.getMonth()==0)? 3f : Math.abs(date1.getMonth() - date2.getMonth());
		float dayDifference = (date1.getDay()==0 || date2.getDay()==0)? 5f: Math.abs(date1.getDay() - date2.getDay());
		
		yearScore = Math.max(10-yearDifference, 0)/10f*6/10f;
		monthScore = Math.max(6-monthDifference, 0)/6f*2/10f;
		dayScore = Math.max(10-dayDifference, 0)/10f*2/10f;
		
		totalScore = yearScore+monthScore+dayScore;
		return (double)totalScore;
	}
	
	public static void main(String[] args) {
		DateComparator c = new DateComparator ();
		Date date1 = new Date("04 APR 2007");
		Date date2 = new Date("04 APR 1900");
		System.out.println(c.compareDates(date1, date2));
		
	}
}
